package com.fenghongzhang.day014;

import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Main2Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);


    }

    public void btn(View view) {
        //创建对话框
        ProgressDialog progressDialog = new ProgressDialog(this);
        progressDialog.setTitle("标题");
        progressDialog.setIcon(R.mipmap.ic_launcher);
        progressDialog.setMessage("message");
        //样式
        progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        progressDialog.setMax(200);
        //确定
        progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(Main2Activity.this, "确定", Toast.LENGTH_SHORT).show();
            }
        });
        //取消
        progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "不ok", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(Main2Activity.this, "取消", Toast.LENGTH_SHORT).show();
            }
        });
        //显示
        progressDialog.show();
        //进度值
        progressDialog.setProgress(50);
        //第二个进度
        progressDialog.setSecondaryProgress(100);

        //就是让对话框消息
//        progressDialog.dismiss();

    }
}
